Conversation
| pub struct OnboardArgs { | ||
| pub openrouter_api_key: Option<String>, | ||
| // Add other API key fields as needed | ||
| pub anthropic_api_key: Option<String>, | ||
| pub openai_api_key: Option<String>, | ||
| pub gemini_api_key: Option<String>, | ||
| pub xai_api_key: Option<String>, | ||
| pub reset: bool, | ||
| } |
There was a problem hiding this comment.
🔴 opencode_api_key CLI flag silently ignored — not forwarded to TUI OnboardArgs
The CLI's OnboardArgs declares opencode_api_key (crates/rustyclaw-cli/src/main.rs:228-229) and accepts it via --opencode-api-key or the OPENCODE_API_KEY env var. However, when constructing TuiOnboardArgs at lines 662-669, opencode_api_key is never forwarded. The TUI's OnboardArgs struct (crates/rustyclaw-tui/src/onboard.rs:21-29) also lacks this field entirely. Additionally, the provider auto-selection logic (onboard.rs:339-358) and the API key matching logic (onboard.rs:409-415) have no case for "opencode". This means users who pass --opencode-api-key or set OPENCODE_API_KEY will have their key silently ignored — the OpenCode Zen provider won't be auto-selected and the key won't be stored.
Prompt for agents
Three changes are needed:
1. In crates/rustyclaw-tui/src/onboard.rs, add an opencode_api_key field to the OnboardArgs struct at line 27 (before xai_api_key):
pub opencode_api_key: Option<String>,
2. In the same file, add an opencode auto-selection branch in the provider selection block (around line 355-358), e.g.:
} else if args.opencode_api_key.is_some() {
println!(" {}", t::icon_ok("Auto-selecting OpenCode Zen provider based on --opencode-api-key flag"));
PROVIDERS.iter().find(|p| p.id == "opencode").unwrap()
3. In the same file, add an opencode case to the API key matching logic (around lines 409-415):
"opencode" => args.opencode_api_key.as_ref(),
4. In crates/rustyclaw-cli/src/main.rs, forward the key when constructing TuiOnboardArgs (around line 667):
opencode_api_key: _args.opencode_api_key.clone(),
Was this helpful? React with 👍 or 👎 to provide feedback.
- Modified run_onboard_wizard to accept OnboardArgs with API key flags - Added logic to auto-select OpenRouter when --openrouter-api-key is provided - Extended auto-selection to other providers (Anthropic, OpenAI, Google, xAI) - Skip interactive provider selection when API key flag is present - Automatically store the provided API key during authentication Usage: rustyclaw onboard --openrouter-api-key <key> This will now automatically select OpenRouter as the provider instead of showing the interactive selection menu.
94f9be7 to
4c8b73e
Compare
Summary
Fixes issue #109 by implementing automatic provider selection when API key flags are provided to the onboard command.
Changes
Behavior
Before
┌──────────────────────────────────────────┐
│ 🦀 RustyClaw Onboarding 🦀 │
└──────────────────────────────────────────┘
⚠ Important: Please read before continuing.
RustyClaw is an agentic coding tool, meaning it can
read, write, and execute code on your machine on your
behalf. Like any powerful tool, it should be used with
care and awareness.
• It can create and modify files in your project
• It can run commands in your terminal
• It can interact with external APIs using your credentials
Always review actions before approving them, especially
in production environments. You are responsible for any
changes made by the tool.
Do you acknowledge and wish to continue? [y/N]:
Onboarding cancelled.
✓ Agent setup results:
✓ uv: uv is already installed (uv 0.10.8).
✓ ollama: Ollama is already installed (ollama version is 0.15.2). Server status: running.
Warnings/errors:
✗ exo: Sync execution not supported for action 'setup'. Use async dispatch.
After
┌──────────────────────────────────────────┐
│ 🦀 RustyClaw Onboarding 🦀 │
└──────────────────────────────────────────┘
⚠ Important: Please read before continuing.
RustyClaw is an agentic coding tool, meaning it can
read, write, and execute code on your machine on your
behalf. Like any powerful tool, it should be used with
care and awareness.
• It can create and modify files in your project
• It can run commands in your terminal
• It can interact with external APIs using your credentials
Always review actions before approving them, especially
in production environments. You are responsible for any
changes made by the tool.
Do you acknowledge and wish to continue? [y/N]:
Onboarding cancelled.
✓ Agent setup results:
✓ uv: uv is already installed (uv 0.10.8).
✓ ollama: Ollama is already installed (ollama version is 0.15.2). Server status: running.
Warnings/errors:
✗ exo: Sync execution not supported for action 'setup'. Use async dispatch.
Testing
Impact